<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript" src="plugins/jQuery/jQuery-2.2.0.min.js"></script>

<title>排班管理</title>

<meta
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
	name="viewport">
<!-- Bootstrap 3.3.6 -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/bootstrap/css/bootstrap.min.css">
<!-- Font Awesome -->
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
<!-- Ionicons -->
<link rel="stylesheet"
	href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css">
<!-- Theme style -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/AdminLTE.min.css">
<!-- AdminLTE Skins. Choose a skin from the css/skins
       folder instead of downloading all of them to reduce the load. -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/skins/_all-skins.min.css">
<!-- iCheck -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/iCheck/flat/blue.css">
<!-- Morris chart -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/morris/morris.css">
<!-- jvectormap -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.css">
<!-- Date Picker -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/datepicker/datepicker3.css">
<!-- Daterange picker -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker-bs3.css">
<!-- bootstrap wysihtml5 - text editor -->
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/dist/css/theme.css"
	media="all">
<style type="text/css">
label {
	font-weight: normal;
}
</style>

</head>

<body class="hold-transition skin-blue sidebar-mini"
	style="font-family:Microsoft YaHei;">
	<div class="wrapper">

		<header class="main-header">
			<!-- Logo -->
			<div class="logo" style="background-color:#ec7500;">
				<!-- logo for regular state and mobile devices -->
				<span class="logo-lg"><b
					style="font-size:18px;margin-left:-40px ">厂车管理系统</b> </span>
			</div>
			<!-- Header Navbar: style can be found in header.less -->
			<nav class="navbar navbar-static-top"
				style="background-color:#ec7500;">
				<!-- Sidebar toggle button-->
				<a href="#" class="sidebar-toggle" data-toggle="offcanvas"
					role="button"> <span class="sr-only">Toggle navigation</span> </a>

				<div class="navbar-custom-menu">
					<ul class="nav navbar-nav">
						<!-- User Account:-->
						<li class="dropdown user user-menu"><span class="hidden-xs"></span>
						</li>
						<li style="color:#ffffff; background:#959595;padding:15px">${sessionScope.CurrentUser.username}</li>
						<li><a><i class="fa fa-sign-out"></i> </a>
						</li>
					</ul>
				</div>
			</nav>
		</header>
		<!-- Left side column. contains the logo and sidebar -->
		<aside class="main-sidebar">
			<!-- sidebar: style can be found in sidebar.less -->
			<section class="sidebar">
				<!-- sidebar menu: : style can be found in sidebar.less -->
				<ul class="sidebar-menu">
		<c:forEach var = "UserRoleActionsId"  items = "${sessionScope.CurrentUserActionsId}">
		  <c:choose>
		    <c:when test ="${UserRoleActionsId == 4 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/showEmps.do"> <i
					class="fa fa-user"></i><span>员工管理</span>
					 </a></li>
					 </c:when>
					 <c:when test ="${UserRoleActionsId == 8 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/showBuses.do"> <i class="fa fa-bus"></i>
					<span>车辆管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 12 }">
			<li class="active treeview"><a href="${pageContext.request.contextPath}/carschedule_all.do"> <i class="fa fa-calendar"></i>
					<span>排班管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 16 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/stationManage.jsp"> <i
					class="fa fa-map-marker"></i> <span>站点管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 20 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/lineManage.jsp"> <i class="fa fa-road"></i>
					<span>线路管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 24 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/findUserFirstPage.do"> <i class="fa fa-user-plus"></i>
					<span>用户管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 28 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/findRoleFirstPage.do"> <i
					class="fa fa-check-square-o"></i> <span>角色管理</span> </a></li>
					</c:when>
					<c:when test ="${UserRoleActionsId == 32 }">
			<li class="treeview"><a href="${pageContext.request.contextPath}/pages/dataSave.jsp"> <i class="fa fa-save"></i>
					<span>数据备份</span> </a></li>
					</c:when>
					</c:choose></c:forEach>
		</ul>
			</section>
			<!-- /.sidebar -->
		</aside>

		<!-- Content Wrapper. Contains page content -->
		<div class="content-wrapper" style="background-color:#f2f2f2;">
			<!-- Main content -->
			<section class="content">

				<form class="navbar-form navbar-left" role="search"
					action="${pageContext.request.contextPath}/carschedule_query.do">
					<div class="form-group">
						<input type="text" class="form-control" id="navbar-search-input"
							placeholder="输入班次" name="runs_id"
							style="width:110px; margin-left:-5px;color:#ffffff;"> <input
							type="text" class="form-control" id="navbar-search-input"
							name="plate" placeholder="输入车牌号"
							style="width:185px;margin-left:-2px;"> <select
							name="line_id" class="form-control"
							style="width:135px;margin-left:-2px;">
							<option>请选择线路号</option>
							<c:forEach var="l" items="${lines}">
								<option value="${l.line_id}">${l.line_id}</option>
							</c:forEach>
						</select> <select name="departure_time" class="form-control"
							style="width:160px;margin-left:-2px;">
							<option>请选择出发日期</option>
							<c:forEach var="c" items="${carsched}">
								<option value="${c.departure_time}">${c.departure_time}</option>
							</c:forEach>
						</select>
					</div>
					<a style="color:#ffffff;cursor:pointer;">
						<button type="submit" class="btn btn-info"
							style="background:none;border:none;">
							<i class="fa   fa-search" style="color:#ff9900;"></i>
						</button> </a>

				</form>
				<a style="padding:0px 6px;margin-top:15px;cursor:pointer;"
					data-toggle="modal" data-target="#myModal"> <i
					class="fa  fa-plus-square" style="color:#ff9900; margin-top:15px;"></i>&nbsp;增加班次
				</a>

				<div class="box" style="margin-top:12px;">
					<div class="box-body"
						style="padding-top:2px;margin:margin-top:-4px;">
						<table class="table table-bordered table-striped">
							<tr>
								<th style="width:55px;text-align:center;">排班号</th>
								<th style="width:40px;text-align:center;">班次</th>
								<th style="width:55px;text-align:center;">车牌号</th>
								<th style="width:55px;text-align:center;">线路号</th>
								<th style="width:55px;text-align:center;">出发时间</th>
								<th style="width:55px;text-align:center;">操作</th>
							</tr>
							<c:forEach var="c" items="${carsched}">
								<tr>
									<td>${c.schedule_id}</td>
									<td>${c.runs_id}</td>
									<td>${c.plate}</td>
									<td>${c.line_id}</td>
									<td>${c.departure_time}</td>
									
									<td style="text-align:center;">
										    <c:forEach var = "actionId" items = "${sessionScope.CurrentUserActionsId}">
								    <c:if test="${actionId == 10 }"> 
									<a href="#"
										data-toggle="modal" data-target="#modify"
										onclick="checkAndUpdate('${c.schedule_id}')"> <i class="fa  fa-edit"
											style="color:#ff9900;margin:0px 15px 0 -10px;"></i> </a>
											</c:if>
											<c:if test="${actionId == 9 }"> 
											<a
										href="${pageContext.request.contextPath}/carschedule_delete.do?schedule_id=${c.schedule_id}">
											<i class="fa  fa-trash" style="color:#ff9900"></i>&nbsp;&nbsp; </a>
											</c:if></c:forEach>
											
											</td>
								</tr>
							</c:forEach>
						</table>
					</div>
					<!-- /.box-body -->
					<div class="box-footer clearfix">
						<ul class="pagination pagination-sm no-margin pull-right">
							<li><a href="changePages.do?currentPage=${sessionScope.pc.previousPage}">&laquo;</a></li>
							<c:forEach var="s" begin="1" end="${sessionScope.pc.totalPages}">
							<li><a href="changePages.do?currentPage=${s}">${s}</a></li>
			                  </c:forEach>
							<li><a href="changePages.do?currentPage=${sessionScope.pc.nextPage}">&raquo;</a></li>
						</ul>
					</div>
				</div>

				<!-- 模态框（Modal） -->
				<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content"
							style="width:400px;height:470px;position:relative; top:50px;left:100px;">
							<div class="modal-header"
								style="color:#ffffff;background:#ff9900;">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">
									<i class="fa  fa-close " style="color:#ffffff"></i>
								</button>
								<h4 class="modal-title" id="myModalLabel">添加班次</h4>
							</div>
							<form class="form-horizontal" role="form" method="post"
								action="${pageContext.request.contextPath}/carschedule_add.do">
								<div class="modal-body"
									style="font-size:14px;font-family:Microsoft YaHei; margin-top:40px;">
									<div class="form-group"
										style="margin-left:-30px; margin-bottom:20px;">
										<label for="lastname" class="col-sm-4 control-label">班次号</label>
										<div class="col-sm-6">

											<input type="text" class="form-control" id="lastname"
												name="runs_id"
												style="background:none;border:1px solid #bcbcbc; color:#000;"
												placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group"
										style="margin-left:-30px;margin-bottom:20px;">
										<label for="lastname" class="col-sm-4 control-label">车牌号</label>
										<div class="col-sm-6">
											<select name="plate" class="form-control"
												style="width:140px;margin-left:-2px;background:none;border:1px solid #bcbcbc; color:#000;">
												<option>请选择车牌号</option>
												<c:forEach var="c" items="${cars}">
													<option>${c.plate}</option>
												</c:forEach>
											</select>
										</div>
									</div>
									<div class="form-group"
										style="margin-left:-30px;margin-bottom:20px;">
										<label for="firstname" class="col-sm-4 control-label">线路号</label>
										<div class="col-sm-6">
											<select name="line_id" class="form-control"
												style="width:140px;margin-left:-2px;background:none;border:1px solid #bcbcbc; color:#000;">
												<option>请选择线路号</option>
												<c:forEach var="l" items="${lines}">
													<option>${l.line_id}</option>
												</c:forEach>
											</select>
										</div>
									</div>
									<div class="form-group"
										style="margin-left:-30px;margin-bottom:20px;">
										<label for="firstname" class="col-sm-4 control-label">发车日期</label>
										<div class="col-sm-6">
											<div class="demo1">
												<input class="laydate-icon" id="departTime" name="departure_time"
													style="height:32px;">
											</div>
										</div>
									</div>

								</div>
								<div class="modal-footer" style="padding:0 30%;">
									<button type="submit" class="btn btn-default"
										style="color:#ffffff;background:#ff9900; margin-top:20px;margin-right:10px;">保&nbsp;存</button>
									<button type="button" class="btn btn-default"
										data-dismiss="modal"
										style="color:#ffffff;background:#a0a0a0;margin-top:20px;">取&nbsp;消
									</button>
								</div>
							</form>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal -->
				</div>
				<!-- 修改弹出框 -->
				<div class="modal fade" id="modify" tabindex="-1" role="dialog"
					aria-labelledby="myModalLabel" aria-hidden="true">
					<div class="modal-dialog">
						<div class="modal-content"
							style="width:400px;height:470px;position:relative; top:50px;left:100px;">
							<div class="modal-header"
								style="color:#ffffff;background:#ff9900;">
								<button type="button" class="close" data-dismiss="modal"
									aria-hidden="true">
									<i class="fa  fa-close " style="color:#ffffff"></i>
								</button>
								<h4 class="modal-title" id="myModalLabel">修改班次</h4>
							</div>
							<form class="form-horizontal" role="form" method="post" action="${pageContext.request.contextPath}/updateCarshed.do">
							<input type="hidden" class="form-control" id="id" name="schedule_id"
												style="background:none;border:1px solid #bcbcbc;color: #000;display: none" placeholder="请输入姓" >
								<div class="modal-body"
									style="font-size:14px;font-family:Microsoft YaHei; margin-top:40px;">
									<div class="form-group"
										style="margin-left:-30px; margin-bottom:20px;">
										<label for="lastname" class="col-sm-4 control-label">班次号</label>
										<div class="col-sm-6">
											<input type="text" class="form-control" id="modifyrun"
												name="runs_id"
												style="background:none;border:1px solid #bcbcbc; color:#000;"
												placeholder="请输入姓">
										</div>
									</div>
									<div class="form-group"
										style="margin-left:-30px;margin-bottom:20px;">
										<label for="lastname" class="col-sm-4 control-label">车牌号</label>
										<div class="col-sm-6">
											<select name="plate" class="form-control" id="modifyplate"
												style="width:140px;margin-left:-2px;background:none;border:1px solid #bcbcbc; color:#000;">
												<option>请选择车牌号</option>
												<c:forEach var="c" items="${cars}">
													<option>${c.plate}</option>
												</c:forEach>
											</select>
										</div>
									</div>
									<div class="form-group"
										style="margin-left:-30px;margin-bottom:20px;">
										<label for="firstname" class="col-sm-4 control-label">线路号</label>
										<div class="col-sm-6">
											<select name="line_id" class="form-control" id="modifyline"
												style="width:140px;margin-left:-2px;background:none;border:1px solid #bcbcbc; color:#000;">
												<option>请选择线路号</option>
												<c:forEach var="l" items="${lines}">
													<option>${l.line_id}</option>
												</c:forEach>
											</select>
										</div>
									</div>
									<div class="form-group"
										style="margin-left:-30px;margin-bottom:20px;">
										<label for="firstname" class="col-sm-4 control-label">发车日期</label>
										<div class="col-sm-6">
											<div class="demo1">
												<input class="laydate-icon" id="demo" name="departure_time" 
													style="height:32px;">
											</div>
										</div>
									</div>

								</div>
								<div class="modal-footer" style="padding:0 30%;">
									<button type="submit" class="btn btn-default"
										style="color:#ffffff;background:#ff9900; margin-top:20px;margin-right:10px;">保&nbsp;存</button>
									<button type="button" class="btn btn-default"
										data-dismiss="modal"
										style="color:#ffffff;background:#a0a0a0;margin-top:20px;">取&nbsp;消
									</button>
								</div>
							</form>
						</div>
						<!-- /.modal-content -->
					</div>
					<!-- /.modal -->
				</div>
			</section>
			<!-- /.content -->
		</div>
		<!-- /.content-wrapper -->

		<!-- ./wrapper -->

		<!-- jQuery 2.2.0 -->
		<script
			src="${pageContext.request.contextPath}/plugins/jQuery/jQuery-2.2.0.min.js"></script>
		<!-- jQuery UI 1.11.4 -->
		<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
		<!-- Resolve conflict in jQuery UI tooltip with Bootstrap tooltip -->
		<script>
			$.widget.bridge('uibutton', $.ui.button);
		</script>
		<!-- Bootstrap 3.3.6 -->
		<script
			src="${pageContext.request.contextPath}/bootstrap/js/bootstrap.min.js"></script>
		<!-- Morris.js charts -->
		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/morris/morris.min.js"></script>
		<!-- Sparkline -->
		<script
			src="${pageContext.request.contextPath}/plugins/sparkline/jquery.sparkline.min.js"></script>
		<!-- jvectormap -->
		<script
			src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
		<!-- jQuery Knob Chart -->
		<script
			src="${pageContext.request.contextPath}/plugins/knob/jquery.knob.js"></script>
		<!-- daterangepicker -->
		<script
			src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.2/moment.min.js"></script>
		<script
			src="${pageContext.request.contextPath}/plugins/daterangepicker/daterangepicker.js"></script>
		<!-- datepicker -->
		<script
			src="${pageContext.request.contextPath}/plugins/datepicker/bootstrap-datepicker.js"></script>
		<!-- Bootstrap WYSIHTML5 -->
		<script
			src="${pageContext.request.contextPath}/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
		<!-- Slimscroll -->
		<script
			src="${pageContext.request.contextPath}/plugins/slimScroll/jquery.slimscroll.min.js"></script>
		<!-- FastClick -->
		<script
			src="${pageContext.request.contextPath}/plugins/fastclick/fastclick.js"></script>
		<!-- AdminLTE App -->
		<script src="${pageContext.request.contextPath}/dist/js/app.min.js"></script>
		<!-- AdminLTE dashboard demo (This is only for demo purposes) -->
		<script
			src="${pageContext.request.contextPath}/dist/js/pages/dashboard.js"></script>
		<!-- AdminLTE for demo purposes -->
		<script src="${pageContext.request.contextPath}/dist/js/demo.js"></script>
		<script src="${pageContext.request.contextPath}/dist/js/jquery.min.js"></script>
		<script src="${pageContext.request.contextPath}/laydate/laydate.js"></script>
		<script>
			!function() {
				laydate({
					elem : '#demo'
				});//绑定元素
			}();
		</script>
</body>
</html>
<script type="text/javascript">
	function checkAndUpdate(schedule_id){
		var ajax_data = "schedule_id="+schedule_id;
		var ajax_url = "${pageContext.request.contextPath}/modify.do";
		var ajax_type = "post";
		$.ajax({
			type : ajax_type,
			url : ajax_url,
			data : ajax_data,
			success : function(msg,status){
				if(status == "success"){
				
					$("#id").val(msg.schedule_id);
					$("#modifyrun").val(msg.runs_id);
					$("#modifyplate").val(msg.plate);
					$("#modifyline").val(msg.line_id);
					$("#departTime").val(msg.departure_time);
					
				}
			} 
		});
	
	}
</script>
